package com.ht.base.system.biz.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ht.base.system.common.pojo.qto.SysPostQTO;
import com.ht.base.system.dao.dao.SysPostDao;
import com.ht.base.system.dao.domain.SysPostDO;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author hdengxian
 * @Date 2023/5/26 15:28
 */
@Component
public class SysPostMapper extends ServiceImpl<SysPostDao, SysPostDO> {
    @Resource
    private SysPostDao sysPostDao;


    public List<SysPostDO> findByCondition(SysPostDO record) {
        return sysPostDao.findByCondition(record);
    }

    public Integer countByCondition(SysPostDO record) {
        return sysPostDao.countByCondition(record);
    }

    public Integer countByCondition(String postName) {
        LambdaQueryWrapper<SysPostDO> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SysPostDO::getPostName, postName);
        Integer count = sysPostDao.selectCount(wrapper);
        if (count == null) {
            count = 0;
        }
        return count;
    }

    public List<SysPostDO> findSysPostList(SysPostQTO qto) {
        qto.setNeedPaging(false);
        return sysPostDao.findSysPostList(qto);
    }

    public Integer findForPageCount(SysPostQTO qto) {
        return sysPostDao.findForPageCount(qto);
    }

    public List<SysPostDO> findForPage(SysPostQTO qto) {
        return sysPostDao.findForPage(qto);
    }

}
